package com.kxmall.web.controller.huishou;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.kxmall.common.annotation.RepeatSubmit;
import com.kxmall.common.annotation.Log;
import com.kxmall.common.core.controller.BaseController;
import com.kxmall.common.core.domain.PageQuery;
import com.kxmall.common.core.domain.R;
import com.kxmall.common.core.validate.AddGroup;
import com.kxmall.common.core.validate.EditGroup;
import com.kxmall.common.enums.BusinessType;
import com.kxmall.common.utils.poi.ExcelUtil;
import com.kxmall.huishou.domain.vo.HsUserSignVo;
import com.kxmall.huishou.domain.bo.HsUserSignBo;
import com.kxmall.huishou.service.IHsUserSignService;
import com.kxmall.common.core.page.TableDataInfo;

/**
 * 用户签到记录
 *
 * @author kxmall
 * @date 2023-11-23
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/huishou/userSign")
public class HsUserSignController extends BaseController {

    private final IHsUserSignService iHsUserSignService;

    /**
     * 查询用户签到记录列表
     */
    @SaCheckPermission("huishou:userSign:list")
    @GetMapping("/list")
    public TableDataInfo<HsUserSignVo> list(HsUserSignBo bo, PageQuery pageQuery) {
        return iHsUserSignService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出用户签到记录列表
     */
    @SaCheckPermission("huishou:userSign:export")
    @Log(title = "用户签到记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HsUserSignBo bo, HttpServletResponse response) {
        List<HsUserSignVo> list = iHsUserSignService.queryList(bo);
        ExcelUtil.exportExcel(list, "用户签到记录", HsUserSignVo.class, response);
    }

    /**
     * 获取用户签到记录详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("huishou:userSign:query")
    @GetMapping("/{id}")
    public R<HsUserSignVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(iHsUserSignService.queryById(id));
    }

    /**
     * 新增用户签到记录
     */
//    @SaCheckPermission("huishou:userSign:add")
//    @Log(title = "用户签到记录", businessType = BusinessType.INSERT)
//    @RepeatSubmit()
//    @PostMapping()
//    public R<Void> add(@Validated(AddGroup.class) @RequestBody HsUserSignBo bo) {
//        return toAjax(iHsUserSignService.insertByBo(bo));
//    }

    /**
     * 修改用户签到记录
     */
//    @SaCheckPermission("huishou:userSign:edit")
//    @Log(title = "用户签到记录", businessType = BusinessType.UPDATE)
//    @RepeatSubmit()
//    @PutMapping()
//    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HsUserSignBo bo) {
//        return toAjax(iHsUserSignService.updateByBo(bo));
//    }

    /**
     * 删除用户签到记录
     *
     * @param ids 主键串
     */
//    @SaCheckPermission("huishou:userSign:remove")
//    @Log(title = "用户签到记录", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public R<Void> remove(@NotEmpty(message = "主键不能为空")
//                          @PathVariable Long[] ids) {
//        return toAjax(iHsUserSignService.deleteWithValidByIds(Arrays.asList(ids), true));
//    }
}
